#include<stdio.h>

int main()
{
	char str[] = "I am a hard-working person!";	

	//写文件
	FILE * f;
	f = fopen("putc.txt", "w");
	char *p = str;
	while(*p!='\0'){
		char c = *p;
		fputc(c,f);     //向文件写入字符
		p++;
	}
	fclose(f);  //关闭流        

	//读文件
	f = fopen("putc.txt", "r");
	int c;
	if(f==NULL){
		printf("打开文件失败!");
		return -1;
	}else{
		while(!feof(f)){
			c = fgetc(f);    //从文件读取字符
			putchar(c);      //输出字符到显示屏
		}
		fclose(f);   //关闭流
	}

	return 0;
}
